package generator.engine.parse.impl;

import generator.engine.parse.ClassInfoParser;
import generator.entity.ClassInfo;
import generator.util.DatabaseUtil;
import generator.util.GenConfig;

import java.sql.SQLException;

/**
 * @author chengsp
 * @date 2019/10/19 15:23
 */
public class JdbcClassInfoParser implements ClassInfoParser {
    private String tableName;
    private GenConfig genConfig;

    public JdbcClassInfoParser(String tableName, GenConfig genConfig) {
        this.tableName = tableName;
        this.genConfig = genConfig;
    }

    @Override
    public ClassInfo parseClassInfo() {
        try {
            return DatabaseUtil.parseClassInfo(tableName, genConfig);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public String type() {
        return "jdbc";
    }
}
